<?php
/**
 * 事件对象
 * 预定义事件：
 * *com_init
 * *application_start
 * create_controller
 * create_action
 * call_action
 * action_end
 * controller_end
 * *application_end
 * exception_raise
 *
 * @author ananda
 */
class Event extends Kernel
{
    protected $attached = array();

    public function trigger($name, $params = array())
    {
        if (!isset($this->attached[$name])) {
            return false;
        }
        foreach ($this->attached[$name] as $func) {
            call_user_func_array($func, $params);
        }
    }

    public function attach($name, $func)
    {
        $this->attached[$name][] = $func;
    }
}
